package com.byxy.action;

import java.util.List;

import javax.annotation.Resource;

import com.byxy.entity.Log;
import com.byxy.service.LogService;

public class LogListAction {

	@Resource
	private LogService logService;

	private Integer page = 1;
	private Integer rows = 10;

	public Integer getPage() {
		return page;
	}

	public void setPage(Integer page) {
		this.page = page;
	}

	public Integer getRows() {
		return rows;
	}

	public void setRows(Integer rows) {
		this.rows = rows;
	}

	private List<Log> list;

	public List<Log> getList() {
		return list;
	}

	public void setList(List<Log> list) {
		this.list = list;
	}

	public String list() {
		long total = logService.count();
		int totalPage = ((int) total + rows - 1) / rows;

		if (page > totalPage) {
			page = 1;
		}
		list = logService.listPage(page, rows);
		return "success";
	}

	/**
	 * ?id=xxx
	 */
	private int id;

	public int getId() {
		return id;
	}

	public void setId(int id) {
		this.id = id;
	}

	/**
	 * 删除
	 */
	public String delete() {
		logService.delete(id);
		return "success";
	}
}
